package com.shutuo.callnumrunstate;

import com.tencent.mmkv.MMKV;

public class MMKVUtils {

    private static String CALL_NUM_FACTORY = "callnumFactory";
    private static String RUNTIME_STATE = "runtimeState";
    private static String CALL_NUM_CONFIG= "callnumConfig";
    private static String CALL_NUM_DATA = "callnumData";
    private static String RUNTIME_EXCEPTION = "runtimeException";

    public static void saveRunstate(String key , String value){
        MMKV mmkv = MMKV.mmkvWithID(key);
        mmkv.encode(RUNTIME_STATE,value);



    }

    public static String getRunstate(String key){
        MMKV mmkv = MMKV.mmkvWithID(key);
        String runtimeState = mmkv.decodeString(RUNTIME_STATE,"null");
        return runtimeState;
    }

    public static void saveCallnumConfig(String key , String value){
        MMKV mmkv = MMKV.mmkvWithID(key);
        mmkv.encode(CALL_NUM_CONFIG,value);
    }

    public static String getCallnumConfig(String key){
        MMKV mmkv = MMKV.mmkvWithID(key);
        String callnumConfig = mmkv.decodeString(CALL_NUM_CONFIG,"null");
        return callnumConfig;
    }

    public static void saveCallnumData(String key, String value){
        MMKV mmkv = MMKV.mmkvWithID(key);
        mmkv.encode(CALL_NUM_DATA,value);
    }

    public static String getCallnumData(String key){
        MMKV mmkv = MMKV.mmkvWithID(key);
        String callnumData = mmkv.decodeString(CALL_NUM_DATA,"null");
        return callnumData;
    }

    public static void saveRuntimeException(String key , String value){
        MMKV mmkv = MMKV.mmkvWithID(key);
        mmkv.encode(RUNTIME_EXCEPTION,value);
    }

    public static String getRuntimeExcption(String key){
        MMKV mmkv = MMKV.mmkvWithID(key);
        String runtimeExcption = mmkv.decodeString(RUNTIME_EXCEPTION,"null");
        return runtimeExcption;
    }

}
